using System;
using System.Globalization;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Xml;
using System.Reflection;
using JigLibX.Physics;
using JigLibX.Collision;
using Services;
using Utilities.Menu.UIElements;

using Utilities.Menu;
using System.Collections.ObjectModel;

using Services.Menu;
using Utilities;

namespace SuperTicTacToe.Menu
{
    public class HighScoresMenu : DrawableGameComponent
    {
        StateManager stateManager;
        InputManager input_manager;
        SpriteBatch spriteBatch;
        SpriteFont arialHuge, titles, names, arial18, arial14, arial16;
        Texture2D emptyTexture, whiteTexture;
        public HighScoresMenu(Game game, StateManager stateManager)
            : base(game)
        {
            this.stateManager = stateManager;
        }
        public override void Initialize()
        {
            spriteBatch = Game.Services.GetService(typeof(SpriteBatch)) as SpriteBatch;
            //StateManager = Game.Services.GetService(typeof(AStateManager)) as StateManager;
            Game.Services.RemoveService(typeof(IInputManager));
            input_manager = new InputManager(Game);
            Game.Components.Add(input_manager);
            input_manager.OnTap += on_tap;
            base.Initialize();
        }
        protected override void LoadContent()
        {
            arialHuge = Game.Content.Load<SpriteFont>("Fonts/Arial54Ptx");

            titles = Game.Content.Load<SpriteFont>("Fonts/Arial26Ptx");
            arial16 = Game.Content.Load<SpriteFont>("Fonts/Arial16Ptx");
            names = Game.Content.Load<SpriteFont>("Fonts/Arial20Ptx");
            arial18 = Game.Content.Load<SpriteFont>("Fonts/Arial18Ptx");
            arial14 = Game.Content.Load<SpriteFont>("Fonts/Arial14Ptx");
            emptyTexture = Game.Content.Load<Texture2D>("Textures/emptyPixel");
            whiteTexture = Game.Content.Load<Texture2D>("Textures/whitePixel");
            var color = new Color(8, 141, 217);
            base.LoadContent();
        }
        protected override void Dispose(bool disposing)
        {
            Game.Services.RemoveService(typeof(IInputManager));
            Game.Components.Remove(input_manager);
            base.Dispose(disposing);
        }
        public void DisposeMenu()
        {
            Game.Services.RemoveService(typeof(IInputManager));
            Game.Components.Remove(input_manager);
            this.Dispose();
        }
        public override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                stateManager.SelectMainMenu();
            }
            base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.White);
            base.Draw(gameTime);
        }
        Point tp = new Point();
        void on_tap(Vector2 tap_position)
        {
            tp.X = (int)tap_position.X;
            tp.Y = (int)tap_position.Y;

            //if (menu.tapped_on(tp))
            //    StateManager.SelectMainMenu();
        }
    }
}
